struct Node {
    value: u32,
    left: Option<Box<Node>>,
    right: Option<Box<Node>>,
}

impl Node {
    fn new() -> Self {
        Node {
            value: 0,
            left: None,
            right: None,
        }
    }

    fn is_equal(tree_a: &Option<Box<Node>>, tree_b: &Option<Box<Node>>) -> bool {
        if tree_a.is_none() && tree_b.is_none() {
            return true;
        }

        // one of the tree is empty
        if tree_a.is_none() || tree_b.is_none() {
            return false;
        }

        let tree_a = tree_a.as_ref().unwrap();
        let tree_b = tree_b.as_ref().unwrap();

        if tree_a.value != tree_b.value {
            return false;
        }

        if !Self::is_equal(&tree_a.left, &tree_b.right) {
            return false;
        }

        if !Self::is_equal(&tree_a.right, &tree_b.left) {
            return false;
        }

        return true;
    }

    fn is_symmetric(&self) -> bool {
        Self::is_equal(&self.left, &self.right)
    }
}

fn main() {
    let mut tree = Node::new();
    tree.left = Some(Box::new(Node::new()));
    println!("is_symmetric: {}", tree.is_symmetric());
}
